<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>车辆信息</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script src="${ctx}/js/jquery-1.11.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/auto_insurance.js" ></script>
		<link rel="stylesheet" href="${ctx}/css/reset.css">
		<link rel="stylesheet" href="${ctx}/css/auto_insurance.css">
  </head>
  <body>
		<header class="policy_details_head"><a href="#"></a>车辆信息</header>
	<ul class="index_list have_card_list">
		<li><em>车主姓名</em><input name="cname" type="text" value="${cname}" readonly="readonly"/></li>
		<li><em>车牌号码</em><input name="carIp" type="text" value="${carIp}" readonly="readonly"/></li>
		<li><em>注册日期</em><input  id='dateadd1' value="" style="color:" name="carDate" type="text" placeholder="请选择车辆注册日期，格式为2015-01-02"/></li>
		<li><em>品牌型号</em><input id='carDrand' name="carDrand" type="text" placeholder="品牌型号，只能输入字母"/></li>
		<li><em>发动机号</em><input id='carEngine' name="carEngine" type="text" placeholder="请输入发动机型号"/></li>
		<li><em>车架号</em><input id='carNo' name="carNo" type="text" placeholder="请输入17位车架号"/></li>
	</ul>
	<a href="#" class="policy_details_btn" id="submin">立即报价</a>
  </body>
  <script type="text/javascript">
  	$(document).ready(function(){
  		$("#submin").click(function(){
  			var cname=$("input[name='cname']").val();
  			var carIp=$("input[name='carIp']").val();
  			var carDate=$("input[name='carDate']").val();
  			var carDrand=$("input[name='carDrand']").val();
  			var carEngine=$("input[name='carEngine']").val();
  			var carNo=$("input[name='carNo']").val();
  			//判断输入的是否为日期类型
  			var   strDate=carDate;
			var  re =/^(\d{4})-(\d{2})-(\d{2})$/; 
			if(re.test(strDate))//判断日期格式符合YYYY-MM-DD标准
			{ 
				//判断品牌型号是不是英文格式
				var reg= /^[A-Za-z]+$/;
				if(reg.test(carDrand)){
					if(carNo.length==17){
						var parm = {
	  					'cname':cname,
	  					'carIp':carIp,
	  					'carDate':carDate,
	  					'carDrand':carDrand,
	  					'carEngine':carEngine,
	  					'carNo':carNo};
		  				$.post('${ctx}/caradd',parm,function(){
		  					window.opener.aaa();
							//alert("添加成功");
							window.close();
						});
					}else{
						$("#carNo").val(carNo+"      未输入或输入错误请重新输入17位有效车架号");
						$("#carNo").attr("style","color:red");
					}
				}else{
					$("#carDrand").val(carDrand+"      未输入或输入错误请重新输入");
					$("#carDrand").attr("style","color:red");
				}
			}else{
				$("#dateadd1").val(carDate+"      未输入或输入错误请重新输入");
				$("#dateadd1").attr("style","color:red");
			}
		
  		})
  	})
 </script>
 <script type="text/javascript">
 	$(document).ready(function(){
 		$("#dateadd1").click(function(){
 			$("#dateadd1").val("");
 			$("#dateadd1").attr("style","color:black");
 		})
 	})
 	$(document).ready(function(){
 		$("#carDrand").click(function(){
 			$("#carDrand").val("");
 			$("#carDrand").attr("style","color:black");
 		})
 	})
 	$(document).ready(function(){
 		$("#carNo").click(function(){
 			$("#carNo").val("");
 			$("#carNo").attr("style","color:black");
 		})
 	})
 	 	$(document).ready(function(){
 		$("#carEngine").click(function(){
 			$("#carEngine").val("");
 		})
 	})
 </script>
 </html>
